-- OperateTable
-- Created by cheny3 Oct/09/2016
-- 操作台

require "game/ui/form/dungeon/special/UIOperateTable"

-- 初始化
function initOperateTable(self)
     self.item:removeAllChildren();

    local function onClicked(sender, eventType)
        if eventType == ccui.TouchEventType.began then
            if self.gridData.state == GRID_STATE_DISABLE then
                -- 已经失效，不处理
                return;
            end

            -- 更新建筑访问
            self:updateBuildingVisit();

            -- 音效
            AudioM.playFx("admix_medal");

            local pos = self.gridData:getPos();

            -- 打开操作台界面
            UIMgr.getCurrentScene():removeFormByName("UIOperateTable");
            local uiForm = UIOperateTable.create();
            UIMgr.getCurrentScene():addForm(uiForm);
        end
    end

    local iconPath = getLevelItemIconPath("operate_table");
    self.icon = ccui.ImageView:create(iconPath);
    self.icon:setTouchEnabled(true);
    self.icon:addTouchEventListener(onClicked);
    self.item:addChild(self.icon);
    self.iconPath = iconPath;
end
